Method and apparatus for presenting graphic codes

ABSTRACT

The present application provides a method and apparatus for presenting a graphic code. The method includes: after detecting that a graphic code page is invoked, starting a front-facing image capture module of a current device to perform image capturing; performing image recognition on a captured image, and if the captured image includes a pre-configured feature of a code scanning module, calculating an offset distance between the code scanning module and a current presentation location of a graphic code; and calculating a target presentation location based on the offset distance, and presenting the graphic code at the target presentation location. Based on the method provided in the present application, a location of a graphic code can be adapted automatically, and a user does not need to perform alignment, thereby improving user experience.

BACKGROUND Technical Field

The present specification relates to the field of Internet technologies, and in particular, to methods and apparatuses for presenting graphic codes.

Description of the Related Art

In modern daily life, it is very common that a graphic code presented on a mobile phone is scanned using a code scanning terminal device to complete functions such as payment, ticket collection, and mutual addition of friends. Generally, it is necessary to place the mobile phone close to the code scanning terminal device, and align the graphic code presented on the mobile phone with a code scanning module of the code scanning terminal device to complete information reading. For example, after a movie ticket is purchased using an APP on the mobile phone, it is necessary to align a graphic code presented on the mobile phone with a code scanning module of a ticket issuing terminal device on the spot to complete scanning and collection of the movie ticket.

Generally, a location of the graphic code presented on the mobile phone relative to a screen of the mobile phone is fixed. A user is required to first determine a location where the graphic code is currently displayed on the mobile phone and accurately place the displayed graphic code within a scanning area of the code scanning module of the code scanning terminal device to successfully scan the code. In addition, some baffles designed to protect code scanning modules exist on some code scanning terminal devices, so some large mobile phones cannot be placed very well and perform code scanning very well, resulting in poor user experience.

BRIEF SUMMARY

Implementations of the present specification provide methods and apparatuses for presenting graphic codes. Technical solutions are as follows.

According to a first aspect of the implementations of the present specification, a method for presenting a graphic code is provided.

The method includes:

after detecting that a graphic code page is invoked, starting a front-facing image capture module of a current device to perform image capturing;

performing image recognition on a captured image, and if the captured image includes a pre-configured feature of a code scanning module, calculating an offset distance between the code scanning module and a current presentation location of a graphic code; and

calculating a target presentation location based on the offset distance, and presenting the graphic code at the target presentation location.

According to a second aspect of the implementations of the present specification, an apparatus for presenting a graphic code is provided, including: an image capture module, configured to:

after detecting that a graphic code page is invoked, start a front-facing image capture module of a current device to perform image capturing;

an offset calculation module, configured to perform image recognition on a captured image, and if the captured image includes a pre-configured feature of a code scanning module, calculate an offset distance between the code scanning module and a current presentation location of a graphic code; and

a calculation and presentation module, configured to calculate a target presentation location based on the offset distance, and present the graphic code at the target presentation location.

According to a third aspect of the implementations of the present specification, a computer device is provided, including at least a memory, a processor, and a computer program that is stored on the memory and that can run on the processor, the processor implementing a method for presenting a graphic code when executing the program, and the method including at least:

after detecting that a graphic code page is invoked, starting a front-facing image capture module of a current device to perform image capturing;

performing image recognition on a captured image, and if the captured image includes a pre-configured feature of a code scanning module, calculating an offset distance between the code scanning module and a current presentation location of a graphic code; and

calculating a target presentation location based on the offset distance, and presenting the graphic code at the target presentation location.

In the technical solutions provided in the implementations of the present specification, a method for presenting a graphic code is provided. Based on the method provided in the present specification, an image is captured by using a front-facing camera module, and it is determined whether the image includes a code scanning module of a code scanning device. After the code scanning module is determined, a graphic code is correspondingly presented at a location of the code scanning module. Compared with the presentation location of the graphic code in the existing technology, in the method provided in the present specification, the location of the graphic code can be adapted automatically, and a user does not need to perform alignment, thereby improving user experience.

It should be understood that the general descriptions above and the detailed descriptions below are merely examples and illustrative, and cannot limit the implementations of the present specification.

In addition, any one of the implementations of the present specification does not need to achieve all the effects above.

BRIEF DESCRIPTION OF DRAWINGS

To describe the technical solutions in the implementations of the present specification or in the existing technologies more clearly, the following briefly describes the accompanying drawings used for describing the implementations or the existing technologies. Clearly, the accompanying drawings in the following descriptions merely show some implementations of the present specification, and a person of ordinary skill in the art can still derive other drawings from these accompanying drawings:

FIG. 1 is a schematic diagram illustrating a code scanning terminal device according to an example implementation of the present specification;

FIG. 2 is a flowchart illustrating a method for presenting a graphic code according to an example implementation of the present specification;

FIG. 3 is another flowchart illustrating a method for presenting a graphic code according to an example implementation of the present specification;

FIG. 4 is another flowchart illustrating a method for presenting a graphic code according to an example implementation of the present specification;

FIG. 5 is a schematic diagram illustrating an apparatus for presenting a graphic code according to an example implementation of the present specification; and

FIG. 6 is a schematic structural diagram illustrating a computer device according to an example implementation of the present specification.

DETAILED DESCRIPTION

Example implementations are described in detail herein, and examples of the example implementations are presented in the accompanying drawings. When the following descriptions relate to the accompanying drawings, unless specified otherwise, same numbers in different accompanying drawings represent same or similar elements. Implementations described in the following example implementations do not represent all implementations consistent with the present specification. On the contrary, the implementations are merely examples of apparatuses and methods that are described in the appended claims in detail and consistent with some aspects of the present specification.

The terms used in the present specification are merely for illustrating specific implementations, and are not intended to limit the present specification. The terms “a” and “the” of singular forms used in the present specification and the appended claims are also intended to include plural forms, unless otherwise specified in the context clearly. It should be further understood that the term “and/or” used in the present specification indicates and includes any or all possible combinations of one or more associated items as listed.

It should be understood that although terms “first,” “second,” “third,” etc., may be used in the present specification to describe various types of information, the information is not limited to the terms. These terms are merely used to differentiate between information of the same type. For example, without departing from the scope of the present specification, first information can also be referred to as second information, and similarly, the second information can be referred to as the first information. Depending on the context, for example, the word “if” used herein can be interpreted as “while”, “when”, or “in response to determining”.

In modern daily life, it is very common that a graphic code presented, e.g., displayed on a screen, on a mobile phone is scanned using a code scanning terminal device, e.g., as shown in FIG. 1, to complete functions such as payment, ticket collection, and mutual addition of friends. Generally, it is necessary to place the mobile phone close to the code scanning terminal device, and align the graphic code presented on the mobile phone with a code scanning module of the code scanning terminal device to complete information reading. For example, after a movie ticket is purchased using an APP on the mobile phone, it is necessary to align a graphic code presented on the mobile phone with a code scanning module of a ticket issuing terminal device on the spot to complete scanning and collection of the movie ticket.

Generally, a location of the graphic code presented on the mobile phone relative to a screen of the mobile phone is fixed. A user is required to first determine a location or an area in which the graphic code on the mobile phone is located and accurately place the graphic code within a scanning area and/or range of the code scanning module of the code scanning terminal device to successfully scan the code. In addition, some baffles designed to protect code scanning modules exist on some code scanning terminal devices, so some large mobile phones cannot be placed very well and perform code scanning very well, resulting in poor user experience.

To address the problem(s) above, implementations of the present specification provide a method for presenting a graphic code and an apparatus for presenting a graphic code used to execute the method. The following describes in detail the method for presenting a graphic code in the implementations. Referring to FIG. 2, the method can include the following steps.

S201. After detecting that a graphic code page is invoked, start a front-facing image capture module of a current device to perform image capturing.

In the present specification, a graphic code is a digital object identifier including a two-dimensional code, a bar code, a character code, or a network domain name. In modern daily life, a two-dimensional code is most widely used. For example, an application scenario of the two-dimensional code is as follows: after a movie ticket is purchased, a ticket purchasing APP generates a specific two-dimensional code for ticket collection, and a user only needs to present the two-dimensional code at a code scanning module of a ticket collection device on the spot to collect the movie ticket. The following descriptions of the present specification also use two-dimensional code as a representative of graphic code.

When the user opens a two-dimensional code page for presentation, it can be considered that the two-dimensional code page is invoked on a client device. At this moment, the front-facing image capture module of the current device can be started, for example, a front-facing camera of the mobile phone can be started to capture an image in front of the mobile phone.

Considering that some devices may not have a front-facing image capture module, a determining step can be added after it is detected that the graphic code page is invoked: first determining whether the current device has a front-facing image capture module, and if the current device does not have a front-facing image capture module, stopping the process of this implementation, or presenting a two-dimensional code using another method.

S202. Perform image recognition on a captured image, and if the captured image includes pre-configured or dynamically-determined feature(s) of a code scanning module, calculate an offset distance between the code scanning module and a current presentation location of a graphic code.

Specifically, before image recognition, a plurality of pieces of feature information about the code scanning module can be stored on a server or the client device in advance, and the feature information are matched with the captured image, to determine whether the captured image includes one of the plurality of pieces of feature information.

Further, the timing to end image capturing can be determined. Generally, when the user does not move the device while holding the device steadily, the image captured at this moment can be used for image recognition, and the offset distance between the code scanning module and the current presentation location of the graphic code is determined. In this case, the offset distance is relatively stable and does not change substantially, e.g., beyond a threshold. As such, it can be detected whether the current device is in a still state. When the device is in a still state and remains in the still state for a duration that exceeds a predetermined or dynamically-generated threshold, image capturing can be ended, and image recognition can be performed on the captured image.

Similarly, considering that some devices may not have sensors that sense the states of these devices, the timing to end image capturing can be determined using another method: continuously performing image capturing, e.g., at a rapid rate that is predetermined or dynamically-determined, and calculating respective offset distances between the code scanning module in different images, e.g., images captured within a most recent period of time such as most recent 2 seconds, 1 second, or 0.5 second, and the current presentation location of the graphic code; and if the difference between a number of the calculated offset distances is within a predetermined or dynamically-generated threshold, e.g., the calculated offset distances within the most recent period of time are within a threshold difference from one another, ending the image capturing, and calculating the target presentation location.

Further, in some cases, the user may place the device at a location deviating from the code scanning module of a code scanning terminal to a large degree, that is, neither the two-dimensional code is aligned with the code scanning module, nor the code scanning module is located in a field of view of the front-facing camera module. In this case, a prompt can be provided to the user. Specifically, after it is determined that the user invokes the two-dimensional code page and steadily holds the device, if the two-dimensional code is not scanned successfully and the captured image after image recognition does not include feature(s) of the code scanning module, a prompt function is enabled, and the user is prompted to place the device again through voice playback or device vibration.

Further, sensor module(s) can also be added around the code scanning module of the code scanning terminal. After user equipment is moved to deviate from the code scanning module, based on detection using the sensor module(s) of the code scanning terminal, voice prompts can be directly provided to prompt the user to move the user equipment upwards/downwards/leftward/rightwards.

S203. Calculate a target presentation location based on the offset distance, and present the graphic code at the target presentation location.

In some cases, the device may not have a front-facing image capture module. As such, the present specification further provides a method for presenting a graphic code used when the current device does not have a front-facing image capture module. Specifically, referring to FIG. 3, the method includes the following steps.

S301. Detect that the current device does not have a front-facing image capture module.

S302. Set at least one presentation location and a presentation time interval.

S303. Sequentially present the graphic code at different presentation locations based on the set presentation time interval.

For example, a central axis of the device can be set as a presentation route, a plurality of presentation locations are set along the central axis, and the two-dimensional code are sequentially presented at the locations according to the set time interval. The user only needs to place the device approximately at the code scanning module and wait for a while, and the two-dimensional code on the screen can move itself and finally align with the code scanning module. Alternatively or in addition, a straight line, curve, circle, or other shape in any predetermined or dynamically-determined direction can be used as the presentation route. The presentation time interval may be fixed or may vary. For example, the presentation time interval may vary depending on the location and/or orientation of the displayed code, how long has the code being presented without achieving a successful scan by the scanning module, or the like.

An implementation of the present specification further provides a more specific method for presenting a graphic code. Referring to FIG. 4, the method can include the following steps.

S401. Detect that a graphic code page is invoked.

S402. Determine whether a current device has an image capture module.

S403. Present a graphic code based on a predetermined or dynamically-generated presentation policy, the predetermined or dynamically-generated presentation policy including at least a policy for presenting the graphic code based on different predetermined or dynamically-generated presentation locations.

S404. Start the front-facing image capture module of the current device to perform image capturing.

S405. After detecting that the current device is in a still state and remains in the still state for a duration that exceeds a predetermined or dynamically-generated threshold, end the image capturing, and perform image recognition on the captured image.

S406. Perform image recognition on the captured image, and if the captured image includes pre-configured feature(s) of a code scanning module, calculate an offset distance between the code scanning module and a current presentation location of the graphic code.

S407. Calculate a target presentation location based on the offset distance, and present the graphic code at the target presentation location.

Corresponding to the method implementations above, an implementation of the present specification further provides an apparatus for presenting a graphic code. Referring to FIG. 5, the apparatus can include an image capture module 510, an offset calculation module 520, and a calculation and presentation module 530.

The image capture module 510 is configured to: after detecting that a graphic code page is invoked, start a front-facing image capture module of a current device to perform image capturing.

The offset calculation module 520 is configured to perform image recognition on a captured image, and if the captured image includes pre-configured feature(s) of a code scanning module, calculate an offset distance between the code scanning module and a current presentation location of a graphic code.

The calculation and presentation module 530 is configured to calculate a target presentation location based on the offset distance, and present the graphic code at the target presentation location.

An implementation of the present specification further provides a computer device. The computer device includes at least a memory, a processor, and a computer program that is stored on the memory and that can run on the processor. The processor implements the method for presenting a graphic code when executing the program. The method includes at least:

after detecting that a graphic code page is invoked, starting a front-facing image capture module of a current device to perform image capturing;

performing image recognition on a captured image, and if the captured image includes pre-configured feature(s) of a code scanning module, calculating an offset distance between the code scanning module and a current presentation location of a graphic code; and

calculating a target presentation location based on the offset distance, and presenting the graphic code at the target presentation location.

FIG. 6 is a more detailed schematic diagram illustrating a hardware structure of a computing device according to an implementation of the present specification. The device can include a processor 1110, a memory 1120, an input/output interface 1130, a communications interface 1140, and a bus 1150. The processor 1110, the memory 1120, the input/output interface 1130, and the communications interface 1140 are communicatively connected to each other inside the device by using the bus 1150.

The processor 1110 can be implemented using a general central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), one or more integrated circuits, etc., and is configured to execute a related program, to implement the technical solutions provided in the implementations of the present specification.

The memory 1120 can be implemented using a read-only memory (ROM), a random access memory (RAM), a static storage device, a dynamic storage device, etc. The memory 1120 can store an operating system and another application program. When the technical solutions provided in the implementations of the present specification are implemented using software or firmware, related program code is stored on the memory 1120, and is invoked and executed by the processor 1110.

The input/output interface 1130 is configured to be connected to an input/output module, to input or output information. The input/output module (not shown in the figure) can be used as a component and configured in the device, or can be externally connected to the device to provide a corresponding function. The input device can include a keyboard, a mouse, a touchscreen, a microphone, various sensors, etc. The output device can include a monitor, a speaker, a vibrator, an indicator, etc.

The communications interface 1140 is configured to be connected to a communications module (not shown in the figure), to implement a communication interaction between the device and another device. The communications module can perform communication in a wired method, e.g., USB or a network cable, or can perform communication in a wireless method, e.g., a mobile network, Wi-Fi, or Bluetooth.

The bus 1150 includes one channel, used to transmit information between components, e.g., the processor 1110, the memory 1120, the input/output interface 1130, and the communications interface 1140, of the device.

It should be noted that although only the processor 1110, the memory 1120, the input/output interface 1130, the communications interface 1140, and the bus 1150 of the device are shown, during specific implementation(s), the device can further include other components needed for implementing normal running. In addition, a person skilled in the art can understand that the device can include only components necessary for implementing the solutions in the implementations of the present specification, but does not necessarily include all components shown in the figure.

An implementation of the present specification further provides a computer readable storage medium on which a computer program is stored. The program implements the method for presenting a graphic code when being executed by a processor, and the method includes at least:

after detecting that a graphic code page is invoked, starting a front-facing image capture module of a current device to perform image capturing;

performing image recognition on a captured image, and if the captured image includes pre-configured feature(s) of a code scanning module, calculating an offset distance between the code scanning module and a current presentation location of a graphic code; and

calculating a target presentation location based on the offset distance, and presenting the graphic code at the target presentation location.

The computer readable medium includes persistent, non-persistent, movable, and unmovable media that can store information by using any method or technology. The information can be a computer readable instruction, a data structure, a program module, or other data. Examples of the computer storage medium include, but are not limited to, a phase change random access memory (PRAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), another type of RAM, a ROM, an electrically erasable programmable read-only memory (EEPROM), a flash memory or another memory technology, a compact disc read-only memory (CD-ROM), a digital versatile disc (DVD) or another optical storage, a cassette magnetic tape, a magnetic tape/magnetic disk storage, another magnetic storage device, or any other non-transmission medium. The computer storage medium can be used to store information accessible by a computing device. Based on the definition in the present specification, the computer readable medium does not include transitory media such as a modulated data signal and carrier.

Because an apparatus implementation corresponds to a method implementation, for related parts, references can be made to related descriptions in the method implementation. The apparatus implementation described above is merely an example. The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the modules can be selected based on actual needs to achieve the objectives of the solutions of the present specification. A person of ordinary skill in the art can understand and implement the implementations of the present application without creative efforts.

It can be understood from the descriptions of the implementations that, a person skilled in the art can clearly understand that the implementations of the present specification can be implemented by using software and a necessary general hardware platform. Based on such an understanding, the technical solutions in the implementations of the present specification essentially or the part contributing to the existing technology can be implemented in a form of a software product. The computer software product can be stored in a storage medium, such as a ROM/RAM, a magnetic disk, or an optical disc, and includes several instructions for instructing a computer device, which can be a personal computer, a server, a network device, etc., to execute the method described in the implementations of the present specification or in some parts of the implementations of the present specification.

The system, apparatus, module, or unit illustrated in the implementations can be implemented by using a computer chip or an entity, or can be implemented by using a product having a certain function. A typical implementation device is a computer, and the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email receiving and sending device, a game console, a tablet computer, a wearable device, or any combination of these devices.

The implementations of the present specification are described in a progressive method. For same or similar parts of the implementations, references can be made to the implementations. Each implementation focuses on a difference from other implementations. Particularly, an apparatus implementation is similar to a method implementation, and therefore is described briefly. For related parts, references can be made to some descriptions in the method implementation. The apparatus implementation described above is merely an example. The modules described as separate parts may or may not be physically separate. During implementation of the solutions in the implementations of the present application, functions of the modules can be implemented in one or more pieces of software and/or hardware. Some or all of the modules can be selected based on an actual need to implement the solutions in the implementations. A person of ordinary skill in the art can understand and implement the implementations of the present application without creative efforts.

The previous descriptions are merely specific implementations of the implementations of the present application. It should be noted that a person of ordinary skill in the art can further make several improvements or polishing without departing from the principles of the implementations of the present specification, and the improvements or polishing shall fall within the protection scope of the implementations of the present specification.

The various embodiments described above can be combined to provide further embodiments. All of the U.S. patents, U.S. patent application publications, U.S. patent applications, foreign patents, foreign patent applications and non-patent publications referred to in this specification and/or listed in the Application Data Sheet are incorporated herein by reference, in their entirety. Aspects of the embodiments can be modified, if necessary to employ concepts of the various patents, applications and publications to provide yet further embodiments.

These and other changes can be made to the embodiments in light of the above-detailed description. In general, in the following claims, the terms used should not be construed to limit the claims to the specific embodiments disclosed in the specification and the claims, but should be construed to include all possible embodiments along with the full scope of equivalents to which such claims are entitled. Accordingly, the claims are not limited by the disclosure. 

The invention claimed is:
 1. A computer device, comprising a memory, one or more processors, and contents stored on the memory, the one or more processors implementing a method when executing the contents, the method comprising: responsive to detecting that a graphic code page is invoked, determining that the computer device has a front-facing image capture module; capturing an image using the front-facing image capture module; determining that the image includes a visual feature of a code scanning module; calculating an offset distance between the code scanning module and a location of the graphic code as currently presented; and causing presentation of the graphic code based, at least in part, on the offset distance.
 2. The computer device according to claim 1, wherein the graphic code includes at least one of a two-dimensional code, a bar code, a character code, or a network domain name.
 3. The computer device according to claim 1, wherein the determining that the captured image includes a visual feature of a code scanning module comprises matching the image with at least one of a plurality of features of the code scanning module.
 4. The computer device according to claim 1, wherein the image is captured when the computer device remains in a still state for a duration that exceeds a threshold.
 5. The computer device according to claim 1, wherein the capturing the image comprises continuously capturing a plurality of images that includes the image.
 6. The computer device according to claim 1, wherein the causing presentation of the graphic code based, at least in part, on the offset distance comprises: determining a target presentation location for presenting the graphic code based, at least in part, on the offset distance; and causing presentation of the graphic code at the target presentation location.
 7. The computer device according to claim 1, wherein the causing presentation of the graphic code based, at least in part, on the offset distance comprises causing presentation of the graphic code at different presentation locations in accordance with a presentation time interval.
 8. A method for presenting a graphic code, comprising: responsive to detecting that a graphic code page is invoked on a user device, determining that the user device has a front-facing image capture module; capturing an image using the front-facing image capture module; determining that the image includes a feature of a code scanning module; calculating an offset distance between the code scanning module and a present location where the graphic code is presented on the user device; and causing presentation of the graphic code based, at least in part, on the offset distance.
 9. The method according to claim 8, wherein the graphic code includes at least one of a two-dimensional code, a bar code, a character code, or a network domain name.
 10. The method according to claim 8, wherein the determining that the captured image includes a feature of a code scanning module comprises matching the image with at least one of a plurality of features of the code scanning module.
 11. The method according to claim 8, wherein the image is captured when the user device remains in a still state for a duration that exceeds a threshold.
 12. The method according to claim 8, wherein the capturing the image comprises continuously capturing a plurality of images that includes the image.
 13. The method according to claim 8, wherein the causing presentation of the graphic code based, at least in part, on the offset distance comprises: determining a target presentation location on the user device for presenting the graphic code based, at least in part, on the offset distance; and causing presentation of the graphic code at the target presentation location.
 14. The method according to claim 8, wherein the causing presentation of the graphic code based, at least in part, on the offset distance comprises causing presentation of the graphic code at different presentation locations in accordance with a presentation time interval.
 15. A system, comprising: one or more processors; and memory storing contents that, when executed by the one or more processors, cause the system to perform actions comprising: responsive to detecting that a graphic code page is invoked on a mobile device, determining that the mobile device has a front-facing image capture module; capturing an image using the front-facing image capture module; determining that the image includes a feature of a code scanning module; calculating an offset distance between the code scanning module and a present location where the graphic code is presented on the mobile device; and causing presentation of the graphic code based, at least in part, on the offset distance.
 16. The system according to claim 15, wherein the determining that the captured image includes a feature of a code scanning module comprises matching the image with at least one of a plurality of features of the code scanning module.
 17. The system according to claim 15, wherein the image is captured when the mobile device remains in a still state for a duration that exceeds a threshold.
 18. The system according to claim 15, wherein the capturing the image comprises continuously capturing a plurality of images that includes the image.
 19. The system according to claim 15, wherein the causing presentation of the graphic code based, at least in part, on the offset distance comprises: determining a target presentation location on the mobile device for presenting the graphic code based, at least in part, on the offset distance; and causing presentation of the graphic code at the target presentation location.
 20. The system according to claim 15, wherein the causing presentation of the graphic code based, at least in part, on the offset distance comprises causing presentation of the graphic code at different presentation locations in accordance with a presentation time interval. 